#ifndef __CM_NAT_MEDIA_SESSION_H__
#define __CM_NAT_MEDIA_SESSION_H__

#include "JingleSession.h"

namespace cm_nat
{
    class MediaSession;

    class MediaSessionListener
    {
    public:
        virtual void onInitiate( MediaSession* p_session ) = 0;
        virtual void onAccept( MediaSession* p_session ) = 0;
        virtual void onCandidate( MediaSession* p_session, Candidate* cand ) = 0;
        virtual void onCheckResult( MediaSession* p_session, int result ) = 0;
        virtual void onSelectCandidate( MediaSession* p_session, Candidate* cand ) = 0;
    };

    class MediaSession: public JingleSession
    {
    public:
        MediaSession();
        ~MediaSession();

        void registerLisener( MediaSessionListener* p_listener );

        //from JingleSession
        int initiate();
        int accept();
        int reject();
        int terminate();

        int sendSessionInitiate();
        int sendSessionAccept();
        int sendCandidate(SocketAddress reflexAddress);
        int sendPeerCheckResult(int result,  SocketAddress peerReflexAddress);
        int sendSelectCandidate(bool res, SocketAddress reflexAddress, SocketAddress peerAddress);

        enum{
            CHECK_RES_FAIL,
            CHECK_RES_SUCCESS
        };

        //from JingleSession
        int parseJingleTag(const Tag* p_tag);

    protected:
        Candidate m_peerCandiate;

        MediaSessionListener* m_listener;
    };
}


#endif